/**
 * Definition for singly-linked list.
 * function ListNode(val) {
 *     this.val = val;
 *     this.next = null;
 * }
 */
/**
 * @param {ListNode} head
 * @param {number} val
 * @return {ListNode}
 */
var deleteNode = function (head, val) {
  let p = dummyHead = new ListNode()
  dummyHead.next = head
  if (head) {
    while (p) {
      if (p.next.val == val) {
        p.next = p.next.next
      }
      p = p.next
    }
  }
};

1, 2, 3, 4